//
//  UIBarButtonItem.swift
//  Documentation
//
//  Created by Toj on 2/7/23.
//

import Foundation

extension UIBarButtonItem {

    
    public enum Style : Int {

        
        case plain = 0

        @available(iOS, introduced: 2.0, deprecated: 8.0, renamed: "UIBarButtonItem.Style.plain")
        case bordered = 1

        case done = 2
    }

    
    public enum SystemItem : Int {

        
        case done = 0

        case cancel = 1

        case edit = 2

        case save = 3

        case add = 4

        case flexibleSpace = 5

        case fixedSpace = 6

        case compose = 7

        case reply = 8

        case action = 9

        case organize = 10

        case bookmarks = 11

        case search = 12

        case refresh = 13

        case stop = 14

        case camera = 15

        case trash = 16

        case play = 17

        case pause = 18

        case rewind = 19

        case fastForward = 20

        @available(iOS 3.0, *)
        case undo = 21

        @available(iOS 3.0, *)
        case redo = 22

        @available(iOS, introduced: 4.0, deprecated: 11.0)
        case pageCurl = 23

        @available(iOS 13.0, *)
        case close = 24
    }
}

@available(iOS 2.0, *)
open class UIBarButtonItem : UIBarItem, NSCoding {

    
    public init()

    public init?(coder: NSCoder)

    public convenience init(image: UIImage?, style: UIBarButtonItem.Style, target: Any?, action: Selector?)

    @available(iOS 5.0, *)
    public convenience init(image: UIImage?, landscapeImagePhone: UIImage?, style: UIBarButtonItem.Style, target: Any?, action: Selector?) // landscapeImagePhone will be used for the bar button image when the bar has Compact or Condensed bar metrics.

    public convenience init(title: String?, style: UIBarButtonItem.Style, target: Any?, action: Selector?)

    public convenience init(barButtonSystemItem systemItem: UIBarButtonItem.SystemItem, target: Any?, action: Selector?)

    public convenience init(customView: UIView)

    
    /// Construct a new fixed space item with the given width.
    @available(iOS 14.0, *)
    open class func fixedSpace(_ width: CGFloat) -> Self

    
    /// Construct a new flexible space item.
    @available(iOS 14.0, *)
    open class func flexibleSpace() -> Self

    
    open var style: UIBarButtonItem.Style // default is UIBarButtonItemStylePlain

    open var width: CGFloat // default is 0.0

    open var possibleTitles: Set<String>? // default is nil

    open var customView: UIView? // default is nil

    open var action: Selector? // default is NULL

    weak open var target: AnyObject? // default is nil

    
    /// Set the primaryAction on this item, updating the title & image of the item if appropriate (primaryAction is non-nil, and this is not a system item). When primaryAction is non-nil, the target & action properties are ignored. If primaryAction is set to nil, the title & image properties are left unchanged.
    @available(iOS 14.0, *)
    @NSCopying open var primaryAction: UIAction?

    
    /// When non-nil the menu is presented, the gesture used to trigger the menu is based on if the bar button item would normally trigger an action when tapped.
    @available(iOS 14.0, *)
    @NSCopying open var menu: UIMenu?

    
    /// Indicates if the button changes selection as its primary action.
    /// This shows the menu as options for selection if a menu is populated and no action when tapped is enabled.
    /// If no menu is provided and no action is enabled when tapped, the item is toggled on and off for the primary action.
    @available(iOS 15.0, *)
    open var changesSelectionAsPrimaryAction: Bool

    
    @available(iOS 15.0, *)
    open var isSelected: Bool

    
    //
    // Appearance modifiers
    //
    
    /* Send these messages to the [UIBarButtonItem appearance] proxy to customize all buttons, or, to customize a specific button, send them to a specific UIBarButtonItem instance, which may be used in all the usual places in a UINavigationItem (backBarButtonItem, leftBarButtonItem, rightBarButtonItem) or a UIToolbar.
     */
    
    /* In general, you should specify a value for the normal state to be used by other states which don't have a custom value set.
     
     Similarly, when a property is dependent on the bar metrics (on the iPhone in landscape orientation, bars have a different height from standard), be sure to specify a value for UIBarMetricsDefault.
     
     This sets the background image for buttons of any style.
     */
    @available(iOS 5.0, *)
    open func setBackgroundImage(_ backgroundImage: UIImage?, for state: UIControl.State, barMetrics: UIBarMetrics)

    @available(iOS 5.0, *)
    open func backgroundImage(for state: UIControl.State, barMetrics: UIBarMetrics) -> UIImage?

    
    /* This sets the background image for buttons with a specific style. When calling this on a UIBarButtonItem instance, the style argument must match the button's style; when calling on the UIAppearance proxy, any style may be passed.
     */
    @available(iOS 6.0, *)
    open func setBackgroundImage(_ backgroundImage: UIImage?, for state: UIControl.State, style: UIBarButtonItem.Style, barMetrics: UIBarMetrics)

    @available(iOS 6.0, *)
    open func backgroundImage(for state: UIControl.State, style: UIBarButtonItem.Style, barMetrics: UIBarMetrics) -> UIImage?

    
    @available(iOS 5.0, *)
    open var tintColor: UIColor?

    
    /* For adjusting the vertical centering of bordered bar buttons within the bar
     */
    @available(iOS 5.0, *)
    open func setBackgroundVerticalPositionAdjustment(_ adjustment: CGFloat, for barMetrics: UIBarMetrics)

    @available(iOS 5.0, *)
    open func backgroundVerticalPositionAdjustment(for barMetrics: UIBarMetrics) -> CGFloat

    
    /* For adjusting the position of a title (if any) within a bordered bar button
     */
    @available(iOS 5.0, *)
    open func setTitlePositionAdjustment(_ adjustment: UIOffset, for barMetrics: UIBarMetrics)

    @available(iOS 5.0, *)
    open func titlePositionAdjustment(for barMetrics: UIBarMetrics) -> UIOffset

    
    /* The remaining appearance modifiers apply solely to UINavigationBar back buttons and are ignored by other buttons.
     */
    /*
     backgroundImage must be a resizable image for good results.
     */
    @available(iOS 5.0, *)
    open func setBackButtonBackgroundImage(_ backgroundImage: UIImage?, for state: UIControl.State, barMetrics: UIBarMetrics)

    @available(iOS 5.0, *)
    open func backButtonBackgroundImage(for state: UIControl.State, barMetrics: UIBarMetrics) -> UIImage?

    
    @available(iOS 5.0, *)
    open func setBackButtonTitlePositionAdjustment(_ adjustment: UIOffset, for barMetrics: UIBarMetrics)

    @available(iOS 5.0, *)
    open func backButtonTitlePositionAdjustment(for barMetrics: UIBarMetrics) -> UIOffset

    
    /* For adjusting the vertical centering of bordered bar buttons within the bar
     */
    @available(iOS 5.0, *)
    open func setBackButtonBackgroundVerticalPositionAdjustment(_ adjustment: CGFloat, for barMetrics: UIBarMetrics)

    @available(iOS 5.0, *)
    open func backButtonBackgroundVerticalPositionAdjustment(for barMetrics: UIBarMetrics) -> CGFloat
}

extension UIBarButtonItem {

    @available(iOS 14.0, *)
    public convenience init(systemItem: UIBarButtonItem.SystemItem, primaryAction: UIAction? = nil, menu: UIMenu? = nil)

    @available(iOS 14.0, *)
    public convenience init(title: String? = nil, image: UIImage? = nil, primaryAction: UIAction? = nil, menu: UIMenu? = nil)
}

extension UIBarButtonItem : UISpringLoadedInteractionSupporting {
}
